/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "ui表格视口.h"
#include "UI/布局.h"


C_表格视口* C_表格视口::g当前操作表格视口 = nullptr;



static void on_表格视口布局(C_Widget* self, C_Widget** w, uint32 num) {
	f_布局_扩展视口纵向滚动(self->m_父部件, self, C_Widget::g_鼠标.lZ * 40);
}

static void on_表格视口绘制(C_Widget* self, S_2D画布* 画布) {
	C_表格视口* box = (C_表格视口*)self;


	box->m_是否未绘制 = false;
}

static void on_表格视口变换修改(C_Widget* self) {
	C_表格视口* box = (C_表格视口*)self;

	
}



C_表格视口::C_表格视口(S_UI渲染环境 & ctx) : C_Widget(&ctx) {
	mf_布局 = on_表格视口布局;
	mf_绘制 = on_表格视口绘制;
	mf_变换 = on_表格视口变换修改;

	m_是否未绘制 = true;
	g当前操作表格视口 = this;
}

C_表格视口::~C_表格视口() {
}

void C_表格视口::f_数据绘制() {
	if(m_被裁剪) return;

	//uint32 行 = 0;
	m_绘制文本.clear();
	auto 节点 = f_global_get激活节点();
	for (auto& node : 节点) {
		node->f_getStr(m_绘制文本);
		//++行;
	}

	m_更新绘制属性 = true;
}

C_Widget* f_工作区页面_创建表格视口(S_UI渲染环境& ctx) {
	C_表格视口* ui表格视口 = new C_表格视口(ctx);

	f_widget_开启视口属性(ui表格视口);
	ui表格视口->m_扩展视口属性->m_大小 = { 2048, 2048 };

	auto* 滚动窗口 = f_ui_创建滚动框(ctx, true, true, ui表格视口);
	滚动窗口->mf_鼠标滚轮 = nullptr;

	C_表格视口::g当前操作表格视口 = ui表格视口;
	return 滚动窗口;
}
